package com.xinqi.xinqidev.publisher.consumer.listeners;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author xin麒
 * @date 2023/11/20 11:59
 */
@Slf4j
@Component
public class DirectMQListener {


    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "xinqiyayaDirect.queue1", durable = "true"),
            exchange = @Exchange(name = "xinqiyaya.direct", type = ExchangeTypes.DIRECT),
            key ={"red","blue"}
    ))
    public void listenerDirectQueue1(String msg) {
        log.debug("消费者1监听到【xinqiyayaDirect.queue1】队列的消息是"+msg);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "xinqiyayaDirect.queue2", durable = "true"),
            exchange = @Exchange(name = "xinqiyaya.direct", type = ExchangeTypes.DIRECT),
            key ={"red","yellow"}
    ))
    public void listenerDirectQueue2(String msg) {
        log.debug("消费者2监听到【xinqiyayaDirect.queue2】队列的消息是"+msg);
    }

}
